<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户管理系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        :root {
            --primary: #4CAF50; /* 主绿色 */
            --primary-light: #E8F5E9; /* 浅绿色背景 */
            --primary-dark: #388E3C; /* 深绿色 */
            --accent: #8BC34A; /* 辅助绿色 */
            --bg-color: #F8FBF8; /* 极浅背景 */
            --card-color: #FFFFFF; /* 卡片白色 */
            --text-dark: #2E7D32; /* 深绿色文字 */
            --text-light: #757575; /* 灰色文字 */
            --border: #C8E6C9; /* 浅绿色边框 */
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Helvetica Neue', Arial, 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: var(--bg-color);
            color: #333;
            padding: 30px;
            line-height: 1.6;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--border);
        }

        h1 {
            font-size: 24px;
            font-weight: 500;
            color: var(--primary-dark);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        h1:before {
            content: "🌿";
        }

        .btn-group {
            display: flex;
            gap: 12px;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 10px 18px;
            border-radius: 6px;
            font-weight: 500;
            text-decoration: none;
            transition: all 0.2s ease;
            background-color: var(--primary);
            color: white;
            border: none;
            cursor: pointer;
            font-size: 14px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        .btn:hover {
            background-color: var(--primary-dark);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
        }

        .btn-secondary {
            background-color: var(--primary-light);
            color: var(--primary-dark);
            border: 1px solid var(--primary);
        }

        .btn-secondary:hover {
            background-color: var(--primary);
            color: white;
        }

        .card {
            background-color: var(--card-color);
            border-radius: 10px;
            box-shadow: 0 3px 20px rgba(0, 150, 0, 0.08);
            overflow: hidden;
            border: 1px solid var(--border);
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 14px 18px;
            text-align: left;
            border-bottom: 1px solid var(--border);
        }

        th {
            background-color: var(--primary-light);
            color: var(--text-dark);
            font-weight: 600;
            font-size: 14px;
            letter-spacing: 0.5px;
        }

        tr:hover {
            background-color: rgba(76, 175, 80, 0.05);
        }

        .badge {
            display: inline-block;
            padding: 5px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 500;
            min-width: 70px;
            text-align: center;
        }

        .badge-normal {
            background-color: rgba(76, 175, 80, 0.1);
            color: var(--primary-dark);
            border: 1px solid var(--primary);
        }

        .badge-warning {
            background-color: rgba(255, 193, 7, 0.1);
            color: #FF8F00;
            border: 1px solid #FFC107;
        }

        .badge-danger {
            background-color: rgba(244, 67, 54, 0.1);
            color: #D32F2F;
            border: 1px solid #F44336;
        }

        .badge-info {
            background-color: rgba(33, 150, 243, 0.1);
            color: #1565C0;
            border: 1px solid #2196F3;
        }

        .actions {
            display: flex;
            gap: 8px;
        }

        .icon-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 6px;
            transition: all 0.2s ease;
            background-color: rgba(76, 175, 80, 0.1);
            color: var(--primary);
            cursor: pointer;
            border: none;
        }

        .icon-btn:hover {
            background-color: var(--primary);
            color: white;
            transform: scale(1.1);
        }

        .text-muted {
            color: var(--text-light);
            font-size: 13px;
        }

        @media (max-width: 768px) {
            body {
                padding: 15px;
            }

            .header {
                flex-direction: column;
                align-items: flex-start;
                gap: 15px;
            }

            .btn-group {
                width: 100%;
            }

            .btn {
                flex: 1;
                justify-content: center;
            }

            th, td {
                padding: 12px 14px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="header">
        <h1>用户管理系统</h1>
        <div class="btn-group">
            <a href="${pageContext.request.contextPath}/user/home" class="btn btn-secondary">
                <i class="fas fa-user"></i> 用户端
            </a>
            <a href="${pageContext.request.contextPath}/user/add" class="btn">
                <i class="fas fa-plus"></i> 添加用户
            </a>
        </div>
    </div>

    <div class="card">
        <table>
            <thead>
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>电话</th>
                <th>性别</th>
                <th>年龄</th>
                <th>BMI</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${users}" var="user">
                <tr>
                    <td>${user.userid}</td>
                    <td><strong>${user.username}</strong></td>
                    <td>${user.phone}</td>
                    <td>${user.sex}</td>
                    <td>${user.age}</td>
                    <td>
                        <c:choose>
                            <c:when test="${user.bmi < 18.5}">
                                <span class="badge badge-info">${user.bmi} (偏瘦)</span>
                            </c:when>
                            <c:when test="${user.bmi >= 18.5 && user.bmi < 24}">
                                <span class="badge badge-normal">${user.bmi} (正常)</span>
                            </c:when>
                            <c:when test="${user.bmi >= 24 && user.bmi < 28}">
                                <span class="badge badge-warning">${user.bmi} (超重)</span>
                            </c:when>
                            <c:otherwise>
                                <span class="badge badge-danger">${user.bmi} (肥胖)</span>
                            </c:otherwise>
                        </c:choose>
                    </td>
                    <td class="text-muted">${user.createtime}</td>
                    <td>
                        <div class="actions">
                            <a href="${pageContext.request.contextPath}/user/edit/${user.userid}"
                               class="icon-btn"
                               title="编辑">
                                <i class="fas fa-edit"></i>
                            </a>
                            <a href="${pageContext.request.contextPath}/user/delete/${user.userid}"
                               onclick="return confirm('确定删除用户 ${user.username} 吗？')"
                               class="icon-btn"
                               title="删除">
                                <i class="fas fa-trash-alt"></i>
                            </a>
                        </div>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
</body>
</html>